<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>权限列表</title>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/layui/css/layui.css"></link>
<script type="text/javascript" src="__PUBLIC__/Admin/js1/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/layer/layer.js"></script>
<!-- <script>
/*
*live--当点击按钮时，隐藏或显示
*children(i)--遍历对象的i表单
*removeClass()删除指定元素的类
*addClass()添加指定的元素的类
*html()设置被选元素的内容
*
*/
$(function(){
	  $('.enable').live('click',function(){
		  var $linkObj=$(this);
		  var $imgObj=$(this).children('i');
		  $.post('__APP__/Admin/Role/disable','id='+$(this).attr('data-id'),function(){
			  $linkObj.removeClass('enable').addClass('disable');
			  $imgObj.html('<i class="layui-icon" >&#xe616;</i>');
		  });
	  })
	  $('.disable').live('click',function(){
		  var linkObj=$(this);
		  var imgObj=$(this).children('i');
		  var id=$(this).attr('data-id');
		  var status=$(this).attr('data-status');
		  
		   $.post('__APP__/Admin/Role/enable',{id:id,status:status},function(){
			  linkObj.removeClass('disable').addClass('enable');
			  imgObj.html('<i class="layui-icon">&#x1007;</i>');
			
		  });
	  }) 
})
             
</script> -->
</head>
<body>
<table class="layui-table" >
  <colgroup>
    <col width="150">
    <col width="200">
    <col>
  </colgroup>
  <thead>
    <tr>
      <th>权限标题</th>
      <th>Urls</th>
      <th>加入时间</th>
      <th>状态</th>
      <th>操作</th>
    </tr> 
  </thead>
  <tbody>
  <if condition ="$arr">
   <foreach name="arr" item="v" key="k">
    <tr class="a{$v.id}">
      <td>{$v.title}</td>
      <td>{$v.urls|json_decode}</td>
      <td>{$v.updated_time}</td>
      <if condition="$v.status eq 1">
      <td><a href="javascript:void(0)" class="enable" data-id="{$v.id}" data-status="{$v.status}"><i class="layui-icon" >&#xe616;</i></a></td>
      <else/>
      <td><a href="javascript:void(0)" class="disable" data-id="{$v.id}"><i class="layui-icon">&#x1007;</i></a></td>
      </if>
      <td><a href="javascript:void(0)" class="save" data-id="{$v.id}" data-urls="{$v.urls|json_decode}" data-name="{$v.title}" title="编辑"><i class="layui-icon" style="background:#e2e2e2">&#xe642;</i></a>
      &nbsp;&nbsp;
      <a href="javascript:void(0)" class="delete" data-id="{$v.id}" title="删除"><i class="layui-icon" style="background:#e2e2e2">&#xe640;</i></a>
        &nbsp;
      <a href="javascript:void(0)" title="添加" class="add"><i class="layui-icon" style="background:#e2e2e2">&#xe654;</i></a></td>
    </tr>
       </foreach>
       <else/>
       <td colspan="5">暂无权限</td>
       </if>
  </tbody>
</table>
<div>{$pageSrt}</div>
<script>
//点击添加
$('.add').click(function() {
  layer.open({
	  type:2,
	  content:"__APP__/Admin/Access/access_add",
	  area:['600px','400px'],
      title:['编辑权限','background:#e2e2e2;align:center'],
      shift:3,
  })
})
//点击编辑
$('.save').click(function(){
	
	var id=$(this).attr('data-id');
	var urls=$(this).attr('data-urls');
	var title=$(this).attr('data-name');
	layer.open({
		type:2,
		content:"__APP__/Admin/Access/access_save?urls="+urls+"&title="+title+"&id="+id,
	    area:['600px','400px'],
		title:['角色管理','background:#e2e2e2;align:center'],
		shift:3,
	})
}) 
//点击删除
$('.delete').click(function(){
	var id=$(this).attr('data-id');
	layer.confirm('确认要删除吗！',function(){
		$.post("__APP__/Admin/Access/access_delete",{id:id},
		     function(data){
			$('.a'+id).remove();
			   if(data.pass==1){
				   layer.msg('已删除',{icon:1,time:1000});		  
			   } 
		})
	})
})
</script>
</body>
</html>